
#include <cassert>

#include "record.h"

int record::getResult()
{
    return (int) dFields[MAX_FIELD - 1];
}


record::record (int attackType, double duration, string protocolType, string service,
            string flag, double src_bytes, double dst_bytes, double land, double wrongFragment,
            double urgent, double hot, double numFailedLogins, double loggedIn, double numCompromised,
            double rootShell, double suAttempted, double numRoot, double numFileCreations,
            double numShells, double numAccessFiles, double numOutboundCmds, double isHostLogin,
            double isGuestLogin, double count, double srv_count, double serrorRate, 
            double srvSerrorRate, double rerrorRate, double srvRerrorRate, 
            double sameSrvRate, double diffSrvRate, double srvDiffHostRate, 
            double dstHostCount, double dstHostSrvCount, double dstHostSameSrvCount,
            double dstHostDiffSrvRate,
            double dstHostSameSrcPortRate, double dstHostSrcDiffHostRate, double dstHostSerrorRate,
            double dstHostSrvSerrorRate, double dstHostRerrorRate, double dstHostSrvRerrorRate)
{
    dFields[0] = duration;
    if (protocolType == "tcp")
        dFields[1] = 0;
    else if (protocolType == "udp")
        dFields[1] = 1;
    else if (protocolType == "icmp")
        dFields[1] = 2;
    else 
        assert(false);

    if (service == "auth")
        dFields[2] = 0;
    else if (service == "bgp")
        dFields[2] = 1;
    else if (service == "courier")
        dFields[2] = 2;
    else if (service == "csnet_ns")
        dFields[2] = 3;
    else if (service == "ctf")
        dFields[2] = 4;
    else if (service == "daytime")
        dFields[2] = 5;
    else if (service == "discard")
        dFields[2] = 6;
    else if (service == "domain")
        dFields[2] = 7;
    else if (service == "domain_u")
        dFields[2] = 8;
    else if (service == "echo")
        dFields[2] = 9;
    else if (service == "eco_i")
        dFields[2] = 10;
    else if (service == "ecr_i")
        dFields[2] = 11;
    else if (service == "efs")
        dFields[2] = 12;
    else if (service == "exec")
        dFields[2] = 13;
    else if (service == "finger")
        dFields[2] = 14;
    else if (service == "ftp")
        dFields[2] = 15;
    else if (service == "ftp_data")
        dFields[2] = 16;
    else if (service == "gopher")
        dFields[2] = 17;
    else if (service == "hostnames")
        dFields[2] = 18;
    else if (service == "http")
        dFields[2] = 19;
    else if (service == "http_443")
        dFields[2] = 20;
    else if (service == "icmp")
        dFields[2] = 21;
    else if (service == "imap4")
        dFields[2] = 22;
    else if (service == "IRC")
        dFields[2] = 23;
    else if (service == "iso_tsap")
        dFields[2] = 24;
    else if (service == "klogin")
        dFields[2] = 25;
    else if (service == "kshell")
        dFields[2] = 26;
    else if (service == "ldap")
        dFields[2] = 27;
    else if (service == "link")
        dFields[2] = 28;
    else if (service == "login")
        dFields[2] = 29;
    else if (service == "mtp")
        dFields[2] = 30;
    else if (service == "name")
        dFields[2] = 31;
    else if (service == "netbios_dgm")
        dFields[2] = 32;
    else if (service == "netbios_ns")
        dFields[2] = 33;
    else if (service == "netbios_ssn")
        dFields[2] = 34;
    else if (service == "netstat")
        dFields[2] = 35;
    else if (service == "nnsp")
        dFields[2] = 36;
    else if (service == "nntp")
        dFields[2] = 37;
    else if (service == "ntp_u")
        dFields[2] = 38;
    else if (service == "other")
        dFields[2] = 39;
    else if (service == "pm_dump")
        dFields[2] = 40;
    else if (service == "pop_2")
        dFields[2] = 41;
    else if (service == "pop_3")
        dFields[2] = 42;
    else if (service == "printer")
        dFields[2] = 43;
    else if (service == "private")
        dFields[2] = 44;
    else if (service == "remote_job")
        dFields[2] = 45;
    else if (service == "rje")
        dFields[2] = 46;
    else if (service == "shell")
        dFields[2] = 47;
    else if (service == "smtp")
        dFields[2] = 48;
    else if (service == "sql_net")
        dFields[2] = 49;
    else if (service == "ssh")
        dFields[2] = 50;
    else if (service == "sunrpc")
        dFields[2] = 51;
    else if (service == "supdup")
        dFields[2] = 52;
    else if (service == "systat")
        dFields[2] = 53;
    else if (service == "telnet")
        dFields[2] = 54;
    else if (service == "tftp_u")
        dFields[2] = 55;
    else if (service == "tim_i")
        dFields[2] = 56;
    else if (service == "time")
        dFields[2] = 57;
    else if (service == "urh_i")
        dFields[2] = 58;
    else if (service == "urp_i")
        dFields[2] = 59;
    else if (service == "uucp")
        dFields[2] = 60;
    else if (service == "uucp_path")
        dFields[2] = 61;
    else if (service == "vmnet")
        dFields[2] = 62;
    else if (service == "whois")
        dFields[2] = 63;
    else if (service == "X11")
        dFields[2] = 64;
    else if (service == "Z39_50")
        dFields[2] = 65;
    else if (service == "http_2784")
        dFields[2] = 66;
    else if (service == "harvest")
        dFields[2] = 67;
    else if (service == "aol")
        dFields[2] = 68;
    else if (service == "http_8001")
        dFields[2] = 69;
    else if (service == "red_i")
        dFields[2] = 70;
    else 
        assert(false);

    if (flag == "OTH")
        dFields[3] = 0;
    else if (flag == "REJ")
        dFields[3] = 1;
    else if (flag == "RSTO")
        dFields[3] = 2;
    else if (flag == "RSTOS0")
        dFields[3] = 3;
    else if (flag == "RSTR")
        dFields[3] = 4;
    else if (flag == "S0")
        dFields[3] = 5;
    else if (flag == "S1")
        dFields[3] = 6;
    else if (flag == "S2")
        dFields[3] = 7;
    else if (flag == "S3")
        dFields[3] = 8;
    else if (flag == "SF")
        dFields[3] = 9;
    else if (flag == "SH")
        dFields[3] = 10;
    else 
        assert(false);

    dFields[4] = src_bytes;
    dFields[5] = dst_bytes;
    dFields[5] = land;
    dFields[7] = wrongFragment;
    dFields[8] = urgent;
    dFields[9] = hot;
    dFields[10] = numFailedLogins;
    dFields[11] = loggedIn;
    dFields[12] = numCompromised;
    dFields[13] = rootShell;
    dFields[14] = suAttempted;
    dFields[15] = numRoot;
    dFields[16] = numFileCreations;
    dFields[17] = numShells;
    dFields[18] = numAccessFiles;
    dFields[19] = numOutboundCmds;
    dFields[20] = isHostLogin;
    dFields[21] = isGuestLogin;
    dFields[22] = count;
    dFields[23] = srv_count;
    dFields[24] = serrorRate;
    dFields[25] = srvSerrorRate;
    dFields[26] = rerrorRate;
    dFields[27] = srvRerrorRate;
    dFields[28] = sameSrvRate;
    dFields[29] = diffSrvRate;
    dFields[30] = srvDiffHostRate;
    dFields[31] = dstHostCount;
    dFields[32] = dstHostSrvCount;
    dFields[33] = dstHostSameSrvCount;
    dFields[34] = dstHostDiffSrvRate;
    dFields[35] = dstHostSameSrcPortRate;
    dFields[36] = dstHostSrcDiffHostRate;
    dFields[37] = dstHostSerrorRate;
    dFields[38] = dstHostSrvSerrorRate;
    dFields[39] = dstHostRerrorRate;
    dFields[40] = dstHostSrvRerrorRate;

    dFields[41] = attackType;

}



